<?php


namespace app\manage\controller;

use app\common\model\Notice as NoticeModel;
class Notice extends Base
{
    public function index(){
        $data = NoticeModel::where("type",NoticeModel::TYPE_NOTICE)->paginate(10);
        return view('',[
            'data'  => $data,
            'count' => $data->total(),
            'page'  => $data->currentPage(),
            'limit' => $data->listRows(),
        ]);
    }

    public function introduce(){
        $data = NoticeModel::where("type",NoticeModel::TYPE_INTRODUCE)->find();

        return view('/introduce',[
            'info' => $data
        ]);
    }
    public function saveIntroduce(){
        $content = input('content');
        $title = input('title');
        $type = input('type');
        $data = NoticeModel::where("type",NoticeModel::TYPE_INTRODUCE)->find();
        $data->content = $content;
        $data->title = $title;
        $data->type = $type;
        if ($data->save()){
            return j(0,'操作成功');
        }
        return j(1,'操作失败');
    }

}